package com.hooper.iot.entity;

import com.hooper.iot.constants.HttpStatus;

/**
 * @author WANGCHENG
 * @ Copyright
 * @ Author     ：wangcheng.
 * @ Date       ：Created in 13:52 2022/4/25
 * @ Description：
 * @ Modified By：
 * @Version: $
 */
public class CommonResponse<T> {
    private String message;
    private Integer code;
    private T data;

    public CommonResponse(String message, Integer code, T data) {
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public static <T> CommonResponse<T> success(String message) {
        return new CommonResponse<>(message, HttpStatus.OK, null);
    }

    public static <T> CommonResponse<T> success(String message, T data) {
        return new CommonResponse<>(message, HttpStatus.OK, data);
    }

    public static <T> CommonResponse<T> failed(String message) {
        return new CommonResponse<>(message, HttpStatus.FAILED, null);
    }

    public static <T> CommonResponse<T> failed(String message, T data) {
        return new CommonResponse<>(message, HttpStatus.FAILED, data);
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
